﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;

namespace ChoMy.Helpers
{
    public class StringHelper
    {
        public string Unsigned(string str)
        {
            Regex regex = new Regex("\\p{IsCombiningDiacriticalMarks}+");
            string temp = str.Normalize(NormalizationForm.FormD);
            str = regex.Replace(temp, string.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D');
            str = str.ToLower();
            str = new Regex(@"\W|_").Replace(str, @" ");
            str = str.Trim();
            str = new Regex(@"\s+").Replace(str, @"-");

            return str;
        }

        public string TilteCase(string str)
        {
            return System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
        }

        public string PriceFormat(double price, string iso)
        {
            switch (iso.ToLower())
            {
                case "usd":
                    return string.Format("{0:C}", price);
                case "vnd":
                    return string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN"), "{0:#,###₫}", Math.Round(price / 1000) * 1000);
                default:
                    return price.ToString();
            }
        }
    }
}